package com.android.tnovoselec.schedule.dto;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class ItemsResultHolder {

	private static Map<Integer, List<ItemDto>> allItems = new HashMap<Integer, List<ItemDto>>();

	private ItemsResultHolder() {
	}

	public static void init(Integer day, List<ItemDto> items) {
		allItems.put(day, items);
	}

	public static void clear() {
		allItems.clear();
	}

	public static List<ItemDto> getItemsByDay(Integer day) {
		return allItems.get(day);
	}
	public static void addItemByDay(Integer day, ItemDto item){
		allItems.get(day).add(item);
	}
	public static ItemDto getItemById(int id){
		ItemDto item = null;
		
		Iterator<Integer> it = allItems.keySet().iterator();
		while(it.hasNext()){
			Integer key = it.next();
			for (ItemDto i : allItems.get(key)){
				if (i.getItemId() == id){
					item = i;
				}
			}
		}
		return item;
	}
}
